//
//  CenterTabbar.swift
//  ShiZhe
//
//  Created by 陈卿伟 on 16/8/23.
//  Copyright © 2016年 陈卿伟. All rights reserved.
//

import UIKit

class CenterTabbar: UITabBar {
    
    
    //创建中间的➕按钮button
    lazy var centerIcon:UIButton = {
        let button = UIButton()
        button.setBackgroundImage(UIImage(named:"moreIcon"), forState: UIControlState())
        self.addSubview(button)
        return button
    }()
    
    
    override func layoutSubviews() {
        super.layoutSubviews()
        let width = self.bounds.size.width/3
        let height = self.bounds.size.height
        var count = 0
        
        //将tabbar的所有子控件取出来，
        for subview in subviews{
            if (subview is UIControl) && !(subview is UIButton){
                subview.frame = CGRect(x: width*CGFloat(count), y: 0, width: width, height: height)
                count += 2
            }
            if count == 3{
                break
            }
        }
        centerIcon.frame = CGRect(x: 154*SCALEW, y: -18, width: 64, height: 64)
        //按钮左边一小半按下去 就跳转到home去了 看来被什么给盖住了  所以将centerIcon提到最上面
        self.bringSubviewToFront(centerIcon)
        
    }
    
}
